package com.yanfan.zutai.service.impl;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.zutai.domain.BDeviceUpgrade;
import com.yanfan.zutai.mapper.BDeviceUpgradeMapper;
import com.yanfan.zutai.service.IBDeviceUpgradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 固件升级Service业务层处理
 *
 * @author ruoyi
 * @date 2023-11-06
 */
@Service
public class BDeviceUpgradeServiceImpl implements IBDeviceUpgradeService {
    @Autowired
    private BDeviceUpgradeMapper bDeviceUpgradeMapper;

    /**
     * 查询固件升级
     *
     * @param id 固件升级主键
     * @return 固件升级
     */
    @Override
    public BDeviceUpgrade selectBDeviceUpgradeById(Long id) {
        return bDeviceUpgradeMapper.selectBDeviceUpgradeById(id);
    }

    /**
     * 查询固件升级列表
     *
     * @param bDeviceUpgrade 固件升级
     * @return 固件升级
     */
    @Override
    public List<BDeviceUpgrade> selectBDeviceUpgradeList(BDeviceUpgrade bDeviceUpgrade) {
        return bDeviceUpgradeMapper.selectBDeviceUpgradeList(bDeviceUpgrade);
    }

    /**
     * 新增固件升级
     *
     * @param bDeviceUpgrade 固件升级
     * @return 结果
     */
    @Override
    public int insertBDeviceUpgrade(BDeviceUpgrade bDeviceUpgrade) {
        Snowflake snowflake = IdUtil.getSnowflake(6, 2);
        long id = snowflake.nextId();
        bDeviceUpgrade.setId(id);
        bDeviceUpgrade.setCreateTime(DateUtils.getNowDate());
        return bDeviceUpgradeMapper.insertBDeviceUpgrade(bDeviceUpgrade);
    }

    /**
     * 修改固件升级
     *
     * @param bDeviceUpgrade 固件升级
     * @return 结果
     */
    @Override
    public int updateBDeviceUpgrade(BDeviceUpgrade bDeviceUpgrade) {
        bDeviceUpgrade.setUpdateTime(DateUtils.getNowDate());
        return bDeviceUpgradeMapper.updateBDeviceUpgrade(bDeviceUpgrade);
    }

    /**
     * 批量删除固件升级
     *
     * @param ids 需要删除的固件升级主键
     * @return 结果
     */
    @Override
    public int deleteBDeviceUpgradeByIds(Long[] ids) {
        return bDeviceUpgradeMapper.deleteBDeviceUpgradeByIds(ids);
    }

    /**
     * 删除固件升级信息
     *
     * @param id 固件升级主键
     * @return 结果
     */
    @Override
    public int deleteBDeviceUpgradeById(Long id) {
        return bDeviceUpgradeMapper.deleteBDeviceUpgradeById(id);
    }
}
